## Function to order attributes and levels

order_attributes_levels <- function(att, lev) {

  attribute <- factor(att, levels = Attribute_order)
  level <- factor(lev, levels = Level_order)
  level <- as.numeric(level)
  order1 <- as.numeric(attribute) * 1000 + level
  order2 <- rank(-order1)
  order3 <- -as.numeric(attribute) * 1000 + order2
  rank(order3)

  # order1 <- as.numeric(att) * 100 + as.numeric(lev)
  # order2 <- as.factor(order1) %>% as.numeric()
  # order3 <- max(order2) - order2 + 1
  
  # return(order3)
    
}
